package com.hwg.emp.service.impl;

import java.util.List;

import com.hwg.emp.common.dto.KeysQueryDto;
import com.hwg.emp.common.service.CommonService;
import com.hwg.emp.common.util.DBUtil;
import com.hwg.emp.dao.AskoffDAO;
import com.hwg.emp.dao.DaoFactory;
import com.hwg.emp.dto.AskoffDto;
import com.hwg.emp.dto.PageBean;
import com.hwg.emp.model.AskoffMD;
import com.hwg.emp.model.OvertimeMD;
import com.hwg.emp.service.AskoffService;
public class AskoffServiceImpl extends CommonService implements AskoffService{
	private AskoffDAO askoffDAO= DaoFactory.getDao(AskoffDAO.class); 
	@Override
	public int selectEmpAskoff(String deptId) throws Exception {
		// TODO Auto-generated method stub
		return askoffDAO.selectEmpAskoff(deptId);
	}

	@Override
	public List<AskoffDto> selectEmpAskoff(String deptId,PageBean pageBean) throws Exception {
		// TODO Auto-generated method stub
		return askoffDAO.selectEmpAskoff(deptId,pageBean);
	}

	@Override
	public boolean addEmpAskoff(AskoffDto askoffDto) throws Exception {
		
		DBUtil.beginTranscation();
		boolean flag = false;
		try{
			flag = askoffDAO.addEmpAskoff(askoffDto);
			DBUtil.commitTranscation();
		}catch(Exception e){
			DBUtil.rollbackTranscation();
			e.printStackTrace();
		}
		
		return flag;
	}

	@Override
	public boolean deleteEmpAskoff(String askoffDtoId[]) throws Exception {
		// TODO Auto-generated method stub
		boolean flag=false;
		DBUtil.beginTranscation();
		for (int i = 0; i < askoffDtoId.length; i++) {
			try{
				flag = askoffDAO.deleteEmpAskoff(askoffDtoId[i]);
				DBUtil.commitTranscation();
			}catch(Exception e){
				DBUtil.rollbackTranscation();
				e.printStackTrace();
			}
		}
		return flag;
	}
	
	@Override
	public int selectAskoffByKey(KeysQueryDto dto, List<AskoffMD> pageData) throws Exception {
		// TODO Auto-generated method stub
		return askoffDAO.selectAskoffByKey(dto, pageData);
	}

}
